﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    public class MenuScreen : MainScreen
    {
        

         new public Vector2[] textVector = 
        {
         new Vector2(300, 100),//0 menu
         new Vector2(300, 30),//1 title
         new Vector2(300, 90),//2 pause
         new Vector2(300, 350),//3 resume
         new Vector2(300, 400),//4 new
         new Vector2(300, 450),//5 save
         new Vector2(300, 500),//6 load
         new Vector2(300, 550),//7 quit
         new Vector2(300, 300),//8 question
         new Vector2(300, 350),//9 yes
         new Vector2(450, 350),//10 no
         new Vector2 (0,585), //11 version
         new Vector2(650,550)//12 load
        };
        public MenuScreen()
        {

        }

        ~MenuScreen()
        {

        }
        public void NewGame(SpriteBatch spriteBatch,Texture2D sprite,SpriteFont font)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "New Game", textVector[2], Color.Red);
            spriteBatch.DrawString(font, "START", textVector[12], Color.Red);
            spriteBatch.End();
        }
        public void SaveGame(SpriteBatch spriteBatch, Texture2D sprite, SpriteFont font)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "Save Game", textVector[2], Color.Red);
            spriteBatch.DrawString(font, "SAVE", textVector[12], Color.Red);
            spriteBatch.End();
        }
        public void LoadGame(SpriteBatch spriteBatch, Texture2D sprite, SpriteFont font)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "Load Game", textVector[2], Color.Red);
            spriteBatch.DrawString(font, "LOAD", textVector[12], Color.Red);
            spriteBatch.End();
        }
        public void PauseGame(SpriteBatch spriteBatch, Texture2D sprite, SpriteFont font)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "Game Paused", textVector[2], Color.Red);
            spriteBatch.End();
        }
        public void ExitGame(SpriteBatch spriteBatch, MouseState CurrentMouseState,Texture2D sprite, SpriteFont font, int menuPosition)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "Quit", textVector[0], Color.Red);
            spriteBatch.DrawString(font, "Are You Sure?", textVector[8], Color.Red);
            spriteBatch.DrawString(font, "Yes", textVector[9], Color.Red);
            spriteBatch.DrawString(font, "No", textVector[10], Color.Red);
            spriteBatch.End();

            if ((CurrentMouseState.X > textVector[9].X && CurrentMouseState.X < textVector[9].X + 100) &&
            (CurrentMouseState.Y > textVector[9].Y && CurrentMouseState.Y < textVector[9].Y + 50))
            {
                if (menuPosition == 5)
                {
                    spriteBatch.Begin();
                    spriteBatch.DrawString(font, "Yes", textVector[9], Color.Yellow);
                    spriteBatch.End();

                    if (CurrentMouseState.LeftButton == ButtonState.Pressed)
                    {

                        System.Diagnostics.Process.GetCurrentProcess().CloseMainWindow();
                    }
                }
            }
            else if ((CurrentMouseState.X > textVector[10].X && CurrentMouseState.X < textVector[10].X + 100) &&
        (CurrentMouseState.Y > textVector[10].Y && CurrentMouseState.Y < textVector[10].Y + 50))
            {
                if (VampireRider.menuPosition == 5)
                {
                    spriteBatch.Begin();
                    spriteBatch.DrawString(font, "No", textVector[10], Color.Yellow);
                    spriteBatch.End();
                    if (CurrentMouseState.LeftButton == ButtonState.Pressed)
                    {

                        VampireRider.menuPosition = 0;
                    }
                }
            }

        }

        public void MenuInteraction(SpriteBatch spriteBatch,MouseState CurrentMouseState, Vector2[] textVector, SpriteFont font, int state, string a, int i,ref int menuPosition)
        {
            if ((CurrentMouseState.X > textVector[i].X && CurrentMouseState.X < textVector[i].X + 100) &&
           (CurrentMouseState.Y > textVector[i].Y && CurrentMouseState.Y < textVector[i].Y + 50))
            {
                Vector2 temp;
                temp = textVector[i];

                spriteBatch.Begin();
                spriteBatch.DrawString(font, a, textVector[i], Color.Yellow);
                spriteBatch.End();
                textVector[i].X -= 70;
                
                spriteBatch.Begin();
                spriteBatch.DrawString(font, ">>>", textVector[i], Color.Yellow);
                spriteBatch.End();
                textVector[i] = temp;

                if (menuPosition == 0)
                {
                    if (CurrentMouseState.LeftButton == ButtonState.Pressed)
                    {
                        menuPosition = state;
                    }
                }
            }
        }
        public override void Draw(SpriteBatch spriteBatch,MouseState CurrentMouseState,Texture2D sprite,SpriteFont font,ref int menuPosition)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(sprite, Vector2.Zero, Color.Wheat);
            spriteBatch.DrawString(font, "Vampire Rider 2D", textVector[1], Color.Red);
            spriteBatch.DrawString(font, "Ye Main Menu", textVector[0], Color.Red);
            spriteBatch.DrawString(font, "Resume", textVector[3], Color.Red);
            spriteBatch.DrawString(font, "New Game", textVector[4], Color.Red);
            spriteBatch.DrawString(font, "Save Game", textVector[5], Color.Red);
            spriteBatch.DrawString(font, "Load Game", textVector[6], Color.Red);
            spriteBatch.DrawString(font, "Quit", textVector[7], Color.Red);
            spriteBatch.End();


            //===========================================RESUME EVENT========================================================
            this.MenuInteraction(VampireRider.spriteBatch,CurrentMouseState, textVector,VampireRider.fonts[0], 1, "Resume", 3, ref VampireRider.menuPosition);
            //===========================================NEW GAME EVENT===================================================
            this.MenuInteraction(VampireRider.spriteBatch, CurrentMouseState, textVector, VampireRider.fonts[0], 2, "New Game", 4, ref VampireRider.menuPosition);
            //===========================================SAVE GAME EVENT===================================================
            this.MenuInteraction(VampireRider.spriteBatch, CurrentMouseState, textVector, VampireRider.fonts[0], 3, "Save Game", 5, ref VampireRider.menuPosition);
            //===========================================LOAD GAME EVENT===================================================
            this.MenuInteraction(VampireRider.spriteBatch, CurrentMouseState, textVector, VampireRider.fonts[0], 4, "Load Game", 6, ref VampireRider.menuPosition);
            //===========================================QUIT EVENT========================================================
            this.MenuInteraction(VampireRider.spriteBatch, CurrentMouseState, textVector, VampireRider.fonts[0], 5, "Quit", 7,ref VampireRider.menuPosition);

        }
        public void SelectDifficultyLevel(SpriteBatch spriteBatch, MouseState CurrentMouseState,Texture2D sprite, SpriteFont font, int menuPosition)
        {

        }
    }
}
